package main

import "crypto/rand"

// UUID generate uuid by n length
func UUID(n int) string {
	const charMap = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"
	buf := make([]byte, n)
	_, err := rand.Read(buf)
	assert(err)
	l := len(charMap)
	for i := range buf {
		idx := int(buf[i]) % l
		buf[i] = charMap[idx]
	}
	return string(buf)
}
